<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>出库主页</title>
<meta name="decorator" content="default" />
<style type="text/css">
.container {
	width: 100%;
}
</style>
<script type="text/javascript">
	function doSave(form) {
		if (${ inventoryOut.systemProducts[0]!=null}
				|| ${inventoryOut.storeselfProducts[0]!=null}) {
			var content = "在保存出库单前，请再次确认本次出库产品信息是否全部正确？";
			global.confirm(content, function() {
				form.submit();
			});

		} else {
			global.confirm("请先登记全部出库产品", function() {
			});
		}
		return false;
	}

	function doCancel() {
		var content = "是否取消本次出库操作？";
		global.confirm(content, function() {
			var url = "${ctx}/inventory/out/product/cancel";
			window.location.href = url;
		});
		return false;
	};

	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>

</head>
<body>
	<form:form id="inventoryOutForm" modelAttribute="inventoryOut"
		action="${ctx}/inventory/out/product/save" method="post"
		class="form-input" onsubmit="return doSave(this)">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden"
			value="${page.pageSize}" />
		<div class="icon-buttons">
			<input type="button" data-inline="true" data-icon="back"
				data-iconpos="notext" onclick="return doCancel()" value="返回" /> <input
				type="submit" data-inline="true" data-icon="check"
				data-iconpos="notext" value="保存提货出库单" />
		</div>

		<div data-role="fieldcontain">
			<label for="employeeID">出库人:</label>
			<form:select id="employeeID" data-native-menu="false"
				path="employee.id" name="employeeID">
				<c:forEach var="e" items="${employees}">
					<option value="${e.id}"
						${e.id==inventoryOut.employee.id?'selected':''}>
						${e.name}</option>
				</c:forEach>
			</form:select>
		</div>
		<div data-role="fieldcontain">
			<label for="dateTime">提货出库时间:</label>
			<form:input id="dateTime" path="dateTime" readonly="true" />
		</div>
		<div data-role="fieldcontain">
			<label for="remark">备注说明:</label>
			<form:textarea id="remark" path="remark" />
		</div>
		<a href="${ctx}/inventory/out/product/addpage" data-inline="true"
			data-role="button">添加产品</a>
	</form:form>
	<form:form id="searchForm" action="${ctx}/inventory/out/product/page"
		method="post" class="form-input">
		<table id="contentTable" data-role="table"
			class="ui-responsive table-stroke">
			<thead>
				<tr>
					<th colspan="7" style="text-align:center;">已选产品</th>
				</tr>
				<tr>
					<th>产品渠道</th>
					<th>产品分类</th>
					<th>出库产品</th>
					<th>出库数量</th>
					<th>零售价</th>
					<th>合计</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="outProduct" items="${page.list}">
					<tr>
						<c:if test="${outProduct.product.product_type==0 }">
							<td>系统产品</td>
							<td>${outProduct.product.product.productCategory.name}</td>
							<td>${outProduct.product.product.name}</td>
							<td>${outProduct.amount}</td>
							<td>${outProduct.product.product.retail_price}</td>
							<td>${outProduct.price}</td>
							<td><a data-role="button" data-inline="true"
								href="${ctx}/inventory/out/product/edit?id=${outProduct.product.id}&pageNo=${page.pageNo}&pageSize=${page.pageSize}">修改</a>&nbsp;&nbsp;
								<a data-role="button" data-inline="true"
								href="${ctx}/inventory/out/product/delete?id=${outProduct.product.id}&pageNo=${page.pageNo}&pageSize=${page.pageSize}">删除</a>&nbsp;&nbsp;
							</td>
						</c:if>

						<c:if test="${outProduct.product.product_type==1 }">
							<td>店面自营</td>
							<td>${outProduct.product.storeSelfProduct.storeSelfProductCategory.name}</td>
							<td>${outProduct.product.storeSelfProduct.name}</td>
							<td>${outProduct.amount}</td>
							<td>${outProduct.product.storeSelfProduct.retail_price}</td>
							<td>${outProduct.price}</td>
							<td><a data-role="button" data-inline="true"
								href="${ctx}/inventory/out/product/edit?id=${outProduct.product.id}&pageNo=${page.pageNo}&pageSize=${page.pageSize}">修改</a>&nbsp;&nbsp;
								<a data-role="button" data-inline="true"
								href="${ctx}/inventory/out/product/delete?id=${outProduct.product.id}&pageNo=${page.pageNo}&pageSize=${page.pageSize}">删除</a>&nbsp;&nbsp;
							</td>
						</c:if>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
	</form:form>
</body>
</html>
